package com.zlq.cn.api;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class SignApiResult<T> {
    public static <T> SignApiResult<T> resultSuccess(T data) {
        return new SignApiResult<>(ApiCodeEnum.SUCCESS.getCode(), ApiCodeEnum.SUCCESS.getMsg(), data);
    }

    public static <T> SignApiResult<T> resultSuccessMessage(String message) {
        return new SignApiResult<>(ApiCodeEnum.SUCCESS.getCode(), message);
    }

    public static <T> SignApiResult<T> resultError(String msg) {
        return new SignApiResult<>(ApiCodeEnum.API_ERROR.getCode(), msg);
    }

    public static <T> SignApiResult<T> resultError(ApiCodeEnum apiCodeEnum) {
        return new SignApiResult<>(apiCodeEnum.getCode(), apiCodeEnum.getMsg());
    }

    public static <T> SignApiResult<T> resultError(String code, String msg, T data) {
        return new SignApiResult<>(code, msg, data);
    }

    @ApiModelProperty("响应码；200正常")
    private String code;

    @ApiModelProperty("响应提示")
    private String msg;

    @ApiModelProperty("响应数据")
    private T data;

    public SignApiResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SignApiResult(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
